package com.itzdl.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Transactional;

import com.itzdl.dao.NewsDao;

import com.itzdl.domain.News;
import com.itzdl.domain.User;
import com.itzdl.service.NewsService;

@Transactional
public class NewsServiceImpl implements NewsService{
	private NewsDao newsDao;
	public void setNewsDao(NewsDao newsDao) {
		this.newsDao = newsDao;
	}
	@Override
	public List<News> findAll() {
		return newsDao.findAll();
	}
	@Override
	public List<News> findByKinds(String news_kinds) {
		// TODO Auto-generated method stub
		return newsDao.findByKinds(news_kinds);
	}
	@Override
	public List<News> findById(Integer news_id) {
		// TODO Auto-generated method stub
		return newsDao.findById(news_id);
	}
	@Override
	public List<News> findByUser(String name) {
		// TODO Auto-generated method stub
		
		return newsDao.findByUser(name);
	}
	@Override
	public List<News> findByTitle(String title) {
		// TODO Auto-generated method stub
		System.out.println(""+title);
		DetachedCriteria dc=DetachedCriteria.forClass(News.class);
		dc.add(Restrictions.like("news_title", "%"+title+"%"));
		return newsDao.findByTitle(dc);
	}
}
